package design.onekey;

import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import design.onekey.annotation.CurrentUserMethodArgumentResolver;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.ArrayList;
import java.util.List;

@SpringBootApplication
@MapperScan("design.onekey.mapper")
public class Demo5ShiroExtendApplication  extends WebMvcConfigurationSupport {

    public static void main(String[] args) {
        SpringApplication.run(Demo5ShiroExtendApplication.class, args);
    }



    /**
     * @Title: addArgumentResolvers
     * @Description: 使获取用户信息注解配置生效
     * @param argumentResolvers
     * @see org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#addArgumentResolvers(java.util.List)
     * @author blcloak
     * @date 2020年5月14日
     */
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        FastJsonHttpMessageConverter fastJsonHttpMessageConverter = new FastJsonHttpMessageConverter();
        List<HttpMessageConverter<?>> converters = new ArrayList<>();
        converters.add(fastJsonHttpMessageConverter);
        argumentResolvers.add(currentUserMethodArgumentResolver());
        super.addArgumentResolvers(argumentResolvers);
    }



    /**
     *<p>Title: currentUserMethodArgumentResolver</p>
     *<p>Description: 获取用户信息注解配置</p>
     * @author blcloak
     * @return
     */
    @Bean
    public CurrentUserMethodArgumentResolver currentUserMethodArgumentResolver() {
        return new CurrentUserMethodArgumentResolver();
    }

}
